<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <title>个人统计</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>个人统计</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>

                    <li class="breadcrumb-item">个人统计</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message alert alert-info" role="status">${flash.message}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                </div>
            </g:if>

        <!-- Hover table card start -->
        <div class="card collapsed">
            <div class="card-header">
                <h5>搜索</h5>

                <div class="card-header-right">

                    <i class="icofont icofont-rounded-down icon-up"></i>
                </div>
            </div>
            <div class="card-block dt-responsive">

                <div class="table-responsive">
                    <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">
                      <g:form method="POST" action="personalList">
                          <div class="row m-0">
                              <div class="col-md-10 p-l-0">
                              <div id="dom-jqry_filter" class="text-left">
                                  <label class="block">
                                  <div class="form-group row">
                                    <div class="col-md-6 intput-daterange input-group">
                                      <input type="text" valctrl="accountStartTime" value="${params?.accountStartTime}" placeholder="客户开始时间" class="form-control form_date">
                                      <input type="hidden" id="accountStartTime" name="accountStartTime" value="date.struct">
                                      <input type="hidden" id="accountStartTime_day" name="accountStartTime_day" value="">
                                      <input type="hidden" id="accountStartTime_month" name="accountStartTime_month" value="">
                                      <input type="hidden" id="accountStartTime_year" name="accountStartTime_year" value="">

                                      <span class="input-group-addon">至</span>

                                      <input type="text" valctrl="accountEndTime" value="${params?.accountEndTime}" placeholder="客户结束时间" class="form-control form_date">
                                      <input type="hidden" id="accountEndTime" name="accountEndTime" value="date.struct">
                                      <input type="hidden" id="accountEndTime_day" name="accountEndTime_day" value="">
                                      <input type="hidden" id="accountEndTime_month" name="accountEndTime_month" value="">
                                      <input type="hidden" id="accountEndTime_year" name="accountEndTime_year" value="">
                                  </div>

                                  <div class="col-md-6 intput-daterange input-group">
                                    <input type="text" valctrl="leadStartTime" value="${params?.leadStartTime}" placeholder="线索开始时间" class="form-control form_date">
                                    <input type="hidden" id="leadStartTime" name="leadStartTime" value="date.struct">
                                    <input type="hidden" id="leadStartTime_day" name="leadStartTime_day" value="">
                                    <input type="hidden" id="leadStartTime_month" name="leadStartTime_month" value="">
                                    <input type="hidden" id="leadStartTime_year" name="leadStartTime_year" value="">

                                    <span class="input-group-addon">至</span>

                                    <input type="text" valctrl="leadEndTime" value="${params?.leadEndTime}" placeholder="线索结束时间" class="form-control form_date">
                                    <input type="hidden" id="leadEndTime" name="leadEndTime" value="date.struct">
                                    <input type="hidden" id="leadEndTime_day" name="leadEndTime_day" value="">
                                    <input type="hidden" id="leadEndTime_month" name="leadEndTime_month" value="">
                                    <input type="hidden" id="leadEndTime_year" name="leadEndTime_year" value="">
                                </div>

                                </div>
                                <div class="form-group row">
                                  <div class="col-md-6 intput-daterange input-group">
                                    <input type="text" valctrl="activityStartTime" value="${params?.activityStartTime}" placeholder="日历开始时间" class="form-control form_date">
                                    <input type="hidden" id="activityStartTime" name="activityStartTime" value="date.struct">
                                    <input type="hidden" id="activityStartTime_day" name="activityStartTime_day" value="">
                                    <input type="hidden" id="activityStartTime_month" name="activityStartTime_month" value="">
                                    <input type="hidden" id="activityStartTime_year" name="activityStartTime_year" value="">

                                    <span class="input-group-addon">至</span>

                                    <input type="text" valctrl="activityEndTime" value="${params?.activityEndTime}" placeholder="日历结束时间" class="form-control form_date">
                                    <input type="hidden" id="activityEndTime" name="activityEndTime" value="date.struct">
                                    <input type="hidden" id="activityEndTime_day" name="activityEndTime_day" value="">
                                    <input type="hidden" id="activityEndTime_month" name="activityEndTime_month" value="">
                                    <input type="hidden" id="activityEndTime_year" name="activityEndTime_year" value="">
                                </div>
                                <div class="col-md-3">
                                    <g:select class="form-control" name="activityStatus" id="activityStatus"
                                    from="${com.next.Activity.constrainedProperties.status.inList}" value="${params?.activityStatus}"
                                    noSelection="${['': '日历状态']}"/>
                                </div>

                              </div>
                              <div class="form-group row">
                                <div class="col-md-6 intput-daterange input-group">
                                  <input type="text" valctrl="opportunityStartTime" value="${params?.opportunityStartTime}" placeholder="商机开始时间" class="form-control form_date">
                                  <input type="hidden" id="opportunityStartTime" name="opportunityStartTime" value="date.struct">
                                  <input type="hidden" id="opportunityStartTime_day" name="opportunityStartTime_day" value="">
                                  <input type="hidden" id="opportunityStartTime_month" name="opportunityStartTime_month" value="">
                                  <input type="hidden" id="opportunityStartTime_year" name="opportunityStartTime_year" value="">

                                  <span class="input-group-addon">至</span>

                                  <input type="text" valctrl="opportunityEndTime" value="${params?.opportunityEndTime}" placeholder="商机结束时间" class="form-control form_date">
                                  <input type="hidden" id="opportunityEndTime" name="opportunityEndTime" value="date.struct">
                                  <input type="hidden" id="opportunityEndTime_day" name="opportunityEndTime_day" value="">
                                  <input type="hidden" id="opportunityEndTime_month" name="opportunityEndTime_month" value="">
                                  <input type="hidden" id="opportunityEndTime_year" name="opportunityEndTime_year" value="">
                              </div>
                              <div class="col-md-3">
                                  <g:select class="form-control" name="opportunityStatus" id="opportunityStatus" optionValue="name"
                                  optionKey="name"
                                  from="${com.next.OpportunityStatus.list()}" value="${params?.opportunityStatus}"
                                  noSelection="${['': '商机状态']}"/>
                                </div>

                            </div>
                              <div class="form-group row">

                              <div class="col-md-6 intput-daterange input-group">
                                <input type="text" valctrl="noteStartTime" value="${params?.noteStartTime}" placeholder="笔记开始时间" class="form-control form_date">
                                <input type="hidden" id="noteStartTime" name="noteStartTime" value="date.struct">
                                <input type="hidden" id="noteStartTime_day" name="noteStartTime_day" value="">
                                <input type="hidden" id="noteStartTime_month" name="noteStartTime_month" value="">
                                <input type="hidden" id="noteStartTime_year" name="noteStartTime_year" value="">

                                <span class="input-group-addon">至</span>

                                <input type="text" valctrl="noteEndTime" value="${params?.noteEndTime}" placeholder="笔记结束时间" class="form-control form_date">
                                <input type="hidden" id="noteEndTime" name="noteEndTime" value="date.struct">
                                <input type="hidden" id="noteEndTime_day" name="noteEndTime_day" value="">
                                <input type="hidden" id="noteEndTime_month" name="noteEndTime_month" value="">
                                <input type="hidden" id="noteEndTime_year" name="noteEndTime_year" value="">
                            </div>

                            </div>

                                  </label>
                              </div>

                          </div>
                              <div class="col-md-2 p-r-0 dt-buttons text-right">
                                  <button class="btn btn-inverse btn-sm btn-squeare" type="submit"><i class="fa fa-search"></i></button>
                                  <button class="btn btn-inverse btn-sm btn-squeare" type="button" id="resetBtn"><i class="fa fa-refresh"></i></button>
                              </div>
                            </div>
                      </g:form>

                    </div>
                </div>

            </div>
        </div>

        <div class="card">
                <div class="card-header">
                    <h5>个人统计</h5>


                </div>

                <div class="card-block">

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">客户</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.totalStatistic?.accountCount}</div>
                        </div>
                        <label class="col-md-2 col-form-label">同部门占比</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                              <g:formatNumber number="${this.totalStatistic?.accountPercent}" minFractionDigits="2"
                                    maxFractionDigits="2"/>%
                            </div>
                        </div>
                    </div>
                    <div class="form-group row">

                        <label class="col-md-2 col-form-label">线索</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.totalStatistic?.leadCount}</div>
                        </div>
                        <label class="col-md-2 col-form-label">同部门占比</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                              <g:formatNumber number="${this.totalStatistic?.leadPercent}" minFractionDigits="2"
                                  maxFractionDigits="2"/>%
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">日历</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.totalStatistic?.activityCount}</div>
                        </div>
                        <label class="col-md-2 col-form-label">同部门占比</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                              <g:formatNumber number="${this.totalStatistic?.activityPercent}" minFractionDigits="2"
                                  maxFractionDigits="2"/>%
                            </div>
                        </div>
                    </div>
                    <div class="form-group row">

                        <label class="col-md-2 col-form-label">商机</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.totalStatistic?.opportunityCount}</div>
                        </div>
                        <label class="col-md-2 col-form-label">同部门占比</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                              <g:formatNumber number="${this.totalStatistic?.opportunityPercent}" minFractionDigits="2"
                                  maxFractionDigits="2"/>%
                            </div>
                        </div>
                    </div>
                    <div class="form-group row">

                        <label class="col-md-2 col-form-label">笔记</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.totalStatistic?.noteCount}</div>
                        </div>
                        <label class="col-md-2 col-form-label">同部门占比</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                              <g:formatNumber number="${this.totalStatistic?.notePercent}" minFractionDigits="2"
                                  maxFractionDigits="2"/>%
                            </div>
                        </div>
                    </div>

                </div>

            </div>
            <!-- Hover table card end -->
            <div class="card">
                <div class="card-header">
                    <h5>客户</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <g:sortableColumn property="name" title="名称" />
                                        <g:sortableColumn property="user" title="所有人" />
                                        <g:sortableColumn property="type" title="类型" />
                                        <g:sortableColumn property="level" title="级别" />
                                        <g:sortableColumn property="website" title="网站" />
                                        <g:sortableColumn property="numberOfEmployees" title="雇员" />
                                        <g:sortableColumn property="registeredCapital" title="注册资本（元）" />
                                        <g:if test="${it?.registeredCapital >= 10000}">
                                            <g:sortableColumn property="registeredCapital" title="注册资本（万元）" />
                                        </g:if>
                                        <g:if test="${it?.registeredCapital >= 100000000}">
                                            <g:sortableColumn property="registeredCapital" title="注册资本（亿）" />
                                        </g:if>
                                        <g:sortableColumn property="parent" title="上级客户" />
                                        <g:sortableColumn property="createdDate" title="创建时间" />
                                        <g:sortableColumn property="modifiedDate" title="修改时间" />
                                    </tr>
                                </thead>
                                <tbody>
                                    <g:each in="${accountList}">
                                        <tr>
                                            <td>
                                                <g:link controller="account" action="show" id="${it.id}" class="firstTd">${it?.name}</g:link>
                                            </td>
                                            <td>${it?.user}</td>
                                            <td>${it?.type?.name}</td>
                                            <td>${it?.level?.name}</td>
                                            <td>${it?.website}</td>
                                            <td>${it?.numberOfEmployees}</td>
                                            <td>${Math.round(new BigDecimal(it?.registeredCapital))}</td>
                                            <td>${it?.parent}</td>

                                            <td>
                                                <g:formatDate date="${it?.createdDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                                            </td>
                                            <td>
                                                <g:formatDate date="${it?.modifiedDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                                            </td>
                                        </tr>
                                    </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>线索</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table id="dom-jqry" class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <g:sortableColumn property="company" title="${message(code: 'lead.company.label', default: '公司')}"></g:sortableColumn>
                                            <g:sortableColumn property="fullName" title="${message(code: 'lead.fullName.label', default: '姓名')}"></g:sortableColumn>
                                            <g:sortableColumn property="industry" title="${message(code: 'lead.industry.label', default: '行业')}"></g:sortableColumn>
                                            <g:sortableColumn property="status" title="${message(code: 'lead.status.label', default: '状态')}"></g:sortableColumn>
                                            <g:sortableColumn property="user" title="${message(code: 'lead.user.label', default: '所有人')}"></g:sortableColumn>
                                            <g:sortableColumn property="createBy" title="${message(code: 'lead.createBy.label', default: '创建人')}"></g:sortableColumn>
                                            <g:sortableColumn property="modifyBY" title="${message(code: 'lead.modifyBY.label', default: '修改人')}"></g:sortableColumn>
                                            <g:sortableColumn property="createdDate" title="${message(code: 'lead.createdDate.label', default: '创建时间')}"></g:sortableColumn>
                                            <g:sortableColumn property="createdDate" title="${message(code: 'lead.modifieddDate.label', default: '修改时间')}"></g:sortableColumn>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <g:each in="${leadList}">
                                        <tr>
                                            <td>
                                                <g:link controller="lead" action="show" id="${it?.id}">${it?.company}</g:link>
                                            </td>
                                            <td>${it?.fullName}</td>
                                            <td>${it?.industry}</td>
                                            <td>${it?.status?.name}</td>
                                            <td>${it?.user}</td>
                                            <td>${it?.createBy}</td>
                                            <td>${it?.modifyBy}</td>
                                            <td>
                                                <g:formatDate format="yyyy-MM-dd HH:mm:ss" date="${it?.createdDate}" />
                                            </td>
                                            <td>
                                                <g:formatDate format="yyyy-MM-dd HH:mm:ss" date="${it?.modifiedDate}" />
                                            </td>
                                        </tr>
                                        </g:each>
                                    </tbody>
                                </table>
                        </div>
                    </div>

                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>日历</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <g:sortableColumn property="name" title="标题" />
                                        <g:sortableColumn property="assignedTo" title="执行人" />
                                        <g:sortableColumn property="type" title="类型" />
                                        <g:sortableColumn property="subType" title="子类型" />
                                        <g:sortableColumn property="status" title="状态" />

                                        <g:sortableColumn property="actualStartTime" title="实际开始时间" />
                                        <g:sortableColumn property="actualEndTime" title="实际结束时间" />
                                        <g:sortableColumn property="createdDate" title="创建时间" />
                                    </tr>
                                </thead>
                                <tbody>
                                    <g:each in="${activityList}">
                                        <tr>
                                            <td>
                                                <g:link controller="activity" action="show" id="${it.id}" class="firstTd">${it?.name}</g:link>
                                            </td>
                                            <td>${it?.assignedTo}</td>
                                            <td>${it?.type?.name}</td>
                                            <td>${it?.subtype?.name}</td>
                                            <td>${it?.status}</td>

                                            <td><g:formatDate date="${it?.actualStartTime}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate></td>
                                            <td><g:formatDate date="${it?.actualEndTime}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate></td>
                                            <td>
                                                <g:formatDate date="${it?.createdDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                                            </td>

                                        </tr>
                                    </g:each>
                                <!-- </tbody> -->
                            </table>
                        </div>
                    </div>

                </div>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>商机</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="serialNumber" title="商机号"></g:sortableColumn>
                                    <g:sortableColumn property="account" title="客户名称"></g:sortableColumn>
                                    <g:sortableColumn property="amount" title="金额"></g:sortableColumn>
                                    <g:sortableColumn property="probability" title="几率"></g:sortableColumn>
                                    <g:sortableColumn property="status" title="状态"></g:sortableColumn>
                                    <g:sortableColumn property="stage" title="阶段"></g:sortableColumn>
                                    <g:sortableColumn property="product" title="产品"></g:sortableColumn>
                                    <g:sortableColumn property="startTime" title="商机发现时间"></g:sortableColumn>
                                    <g:sortableColumn property="endTime" title="客户预计采购时间"></g:sortableColumn>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${opportunityList}">
                                    <tr>
                                        <td>
                                            <g:link controller="opportunity" action="show" id="${it?.id}">${it?.serialNumber}</g:link>
                                        </td>
                                        <td>${it?.account}</td>
                                        <td>${Math.round(new BigDecimal(it?.amount))}</td>
                                        <td>${it?.probability}</td>
                                        <td>${it?.status?.name}</td>
                                        <td>${it?.stage?.name}</td>
                                        <td>${it?.product?.name}</td>
                                        <td><g:formatDate date="${it?.startTime}"
                                                          format="yyyy-MM-dd"></g:formatDate></td>
                                        <td><g:formatDate date="${it?.endTime}"
                                                          format="yyyy-MM-dd"></g:formatDate></td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>笔记</h5>

                    <div class="card-header-right">

                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="user" title="所有人"></g:sortableColumn>
                                    <g:sortableColumn property="subject" title="标题"></g:sortableColumn>

                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${noteList}">
                                    <tr>
                                        <td><g:link controller="note" action="show" id="${it?.id}">${it?.user}</g:link></td>
                                        <td>
                                            ${it?.subject}
                                        </td>

                                    </tr>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>
            </div>

          <!-- Page-body end -->

        </div>
</div>
<g:javascript>

    $(function () {
    $("#resetBtn").click(function () {

        $("#activityStatus").val("");
        $("#select2-activityStatus-container").text("日历状态");
        $("#opportunityStatus").val("");
        $("#select2-opportunityStatus-container").text("商机状态");
        $(".form_date").val("");
        $(".form_date").change();
    })
});

</g:javascript>

</body>

</html>
